//************************************************
//  *Author：jxx
//  *QQ：283591387
//  *自定义业务逻辑扩展
//************************************************
import { mapMutations } from 'vuex';
import extend from './q_aftersale_notarizeExtend.js';
import options from './q_aftersale_notarizeOptions.js';
export default function () {
	return {
		data() {
			let _options = options();
			_options.extend = extend;
			return {
				options: _options
			};
		},
		methods: {
			...mapMutations(['setSalesContractDataStore']),
			onInited() {
				this.editFormOptions.forEach((item) => {
					if (item.field == 'Voucher_sub_aftersale') {
						item.testVal = '点击选择售后服务单';
						item.required = true;
						item.focusUrl = '/pages/aftersaleinfo/q_aftersale/q_aftersale';
					}
				});
			},
			formatter(row, column, index) {
				return '';
			},
			rowClick(index, row, column) {
				return false;
				// return true;
			},
			cellClick(index, row, column) {
				return true;
			},
			rowButtons(index, row) {
				let buttonList = [];
				if (row.AuditStatus === 0) {
					buttonList.push({
						text: '审核',
						type: 'error',
						shape: 'circle'
					});
					if (buttonList.length != 2) {
						buttonList.push({
							text: '编辑',
							type: 'warning',
							shape: 'circle'
						});
					}
				} else {
					buttonList.push({
						text: '查看审核',
						type: 'primary',
						shape: 'circle'
					});
				}
				return buttonList;
			},
			rowButtonClick(btn, index, row) {
				//列表显示的按钮点击事件
				if (btn.text == '编辑') {
					uni.setStorageSync('q_aftersale_notarize', row);
					const optionsObj = {
						editFormOptions: this.options.editFormOptions,
						detailtable: this.options.table
					};
					uni.setStorageSync('optionsObj', JSON.stringify(optionsObj));
					uni.navigateTo({
						url: '/pages/addPage/addPage?biaoming=q_aftersale_notarize&currentAction=Update&ID=Aftersale_notarize&detailTableShow=false'
					});
					return;
				}
				try {
					this.setSalesContractDataStore({ workTable: 'q_aftersale_notarize', tableKey: row.Aftersale_notarize });
					uni.navigateTo({
						url: `/pages/aftersaleinfo/q_aftersale_notarize/q_aftersale_notarizeAduit?workTable=q_aftersale_notarize&&tableKey=` + row.Aftersale_notarize
						// url: `pages/flow/audit/audit?workTable=q_sales_contract&tableKey=${row.Sales_contract}`
					});
				} catch (e) {
					//TODO handle the exception
					console.log(e);
				}
			},
			searchBefore(params) {
				//查询前
				return true;
			},
			updateBefore(formData) {
				//更新保存前操作
				return true;
			},
			addBefore(formData) {
				//新建保存前操作
				return true;
			},
			searchFormOnChange(field, value) {
				//查询弹出框下拉框或日期选中事件
				//if(field=="字段"){
				// 	console.log(value)
				//}
			},
			editFormOnChange(field, value) {
				//新建编辑弹出框下拉框或日期选中事件
				//if(field=="字段"){
				// 	console.log(value)
				//}
			}
		}
	};
}
